<template>
  <div>
    <template v-if="model==1">
      <el-table v-loading="loading" tooltip-effect="darkTable" :data="dataList" border>
        <el-table-column :label="$t('序号')" align="center" show-overflow-tooltip min-width="50">
          <template slot-scope="scope">
            {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('项目名称')" align="center" prop="dealName" show-overflow-tooltip min-width="180">
          <template slot-scope="scope">
            <router-link
              target="_blank"
              :to="{ path:'/deal/home/dealBaseHome', query: { id: scope.row.id, dealType: scope.row.dealType, companyId: scope.row.companyId, menuKey: 'deal_after' }}"
              class="link_a"
            >{{ scope.row.dealName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column v-if="queryParams.dealType === 'bf'" :label="$t('管理公司')" align="center" prop="companyName" show-overflow-tooltip min-width="180">
          <template slot-scope="scope">
            <router-link
              target="_blank"
              :to="{path:'/company/base/companyBaseHome', query: { companyId: scope.row.companyId }}"
              class="link_a"
            >{{ scope.row.companyName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('项目负责人')" align="center" prop="personChargeName" show-overflow-tooltip min-width="100" />
        <!-- 参股基金期限 -->
        <el-table-column v-if="queryParams.dealType === 'bf'" :label="$t('期限')" align="center" prop="bfFundTerm" show-overflow-tooltip min-width="100" />
        <el-table-column v-if="queryParams.dealType === 'bf'" :label="$t('基金规模') + this.$t('金额单位')" align="center" prop="subscribeScale" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            {{ moneyFormat(scope.row.subscribeScale, 'w') }}
          </template>
        </el-table-column>
        <el-table-column v-if="queryParams.dealType === 'debt'" :label="$t('年化收益(%)')" align="center" prop="incomeRate" show-overflow-tooltip min-width="100" />
        <!-- 债权期限 -->
        <el-table-column v-if="queryParams.dealType === 'debt'" :label="$t('期限')" align="center" prop="debtPeriod" show-overflow-tooltip min-width="100" />
        <el-table-column v-if="queryParams.dealType === 'debt'" :label="$t('发行主体')" align="center" prop="issued" show-overflow-tooltip min-width="150" />
        <el-table-column v-if="queryParams.dealType === 'equity'" :label="$t('聚焦行业')" align="center" prop="industryFocus" show-overflow-tooltip min-width="150" />
        <el-table-column v-if="queryParams.dealType === 'equity'" :label="$t('持股比例(%)')" align="center" prop="shareholdingRation" show-overflow-tooltip min-width="100" />
        <el-table-column :label="$t('投资主体')" align="center" prop="investName" show-overflow-tooltip min-width="250" />
        <el-table-column :label="$t('总投资金额') + $t('金额单位')" align="center" prop="amountInvestmentEstimate" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.amountInvestmentEstimate, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('已付款金额') + $t('金额单位')" align="center" prop="amountInvestmentFact" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.amountInvestmentFact, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('已回收金额') + $t('金额单位')" align="center" prop="payBack" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.payBack, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('已回收本金') + $t('金额单位')" align="center" prop="returnPrincipal" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.returnPrincipal, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('已回收收益') + $t('金额单位')" align="center" prop="returnIncome" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.returnIncome, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('最新估值')" align="center" prop="valuation" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.valuation, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('IRR')" align="center" prop="latestIrr" show-overflow-tooltip min-width="100" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </template>
    <template v-else-if="model==2">
      <el-table v-loading="loading" :data="tableList" border>
        <el-table-column :label="$t('项目名称')" show-overflow-tooltip align="center" prop="dealName">
          <template slot-scope="scope">
            <router-link
              target="_blank"
              :to="{path:'/deal/home/dealBaseHome',query:{id:scope.row.dealId,companyId:scope.row.companyId}}"
              class="link_a"
            >{{ scope.row.dealName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('负责人')" align="center" prop="personChargeName" show-overflow-tooltip width="110" />
        <el-table-column :label="$t('聚焦行业')" align="center" prop="industryFocusName" show-overflow-tooltip width="120">
          <template slot-scope="scope">
            <span>{{ $t(scope.row.industryFocusName) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('投资金额') + $t('金额单位')" align="center" prop="investAmount" show-overflow-tooltip width="110">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.investAmount, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('持股比例(%)')" align="center" prop="shareholdingRatio" width="110" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="params.pageNum"
        :limit.sync="params.pageSize"
        @pagination="pageData"
      />
    </template>

  </div>
</template>

<script>
import { listProjectInvestmentSituation, listProjectInvestmentSituationByStatus } from '@/api/deal/projectInvestmentSituation/projectInvestmentSituation'
import { findByIndustryFocus } from '@/api/base/deal/dealBase'

export default {
 data() {
    return {
      total: 0,
      loading: false,
      queryParams: {
        dealType: '',
        status: '',
        dealName: undefined,
        personChargeName: undefined,
        companyName: undefined,
        investName: undefined,
        pageNum: 1,
        pageSize: 10
      },
      dataList: [],
      tableList: [],
      params: {
            pageNum: 1,
            pageSize: 10,
            industryFocus: undefined
          },
      model: 0 // 点击饼图的类别
    }
  },
  created() {
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      this.model = this.$route.params.model
      if (this.$route.params.model && this.$route.params.model === 1) { // 项目类型
         if (this.$route.params.dealType) {
              this.queryParams.dealType = this.$route.params.dealType
         } else if (this.$route.params.areaId) {
           this.queryParams.areaId = this.$route.params.areaId
         }
           // 点击的类型
            listProjectInvestmentSituation(this.queryParams).then(response => {
              this.dataList = response.rows
              this.total = response.total
              this.loading = false
            })
      } else if (this.$route.params.model && this.$route.params.model === 2) { // 聚焦行业
          if (this.$route.params.dealType) {
               this.pageData(this.$route.params.dealType)
          }
      } else if (this.$route.params.model && this.$route.params.model === 3) {
        if (this.$route.params.dealType) {
              this.queryParams.status = this.$route.params.dealType
            }
            this.model = 1
        listProjectInvestmentSituationByStatus(this.queryParams).then(response => {
              this.dataList = response.rows
              this.total = response.total
              this.loading = false
            })
      }
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.companyName = ''
      this.queryParams.personChargeName = ''
      this.queryParams.dealName = ''
      this.queryParams.investName = ''
      this.queryHandle()
    },
      pageData(name) {
          this.params.industryFocus = name
          if (this.$route.params.busType) {
            this.params.type = this.$route.params.busType
          }
          findByIndustryFocus(this.params).then(response => {
            this.tableList = response.rows
            this.total = response.total
            this.loading = false
          })
        }
  }
}

</script>

